<template>
  <div>
    <el-table :data="tab" style="width: 100%">
      <!-- 图片列 -->
      <el-table-column label="封面" width="100">
        <template slot-scope="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.bookImage"
            :preview-src-list="[scope.row.bookImage]"
          ></el-image>
        </template>
      </el-table-column>

      <!-- 书名列 -->
      <el-table-column prop="bookName" label="书名"></el-table-column>

      <!-- 作者列 -->
      <el-table-column prop="bookAuth" label="作者"></el-table-column>
      <el-table-column prop="score" label="收藏量"></el-table-column>
      <!-- 操作列 -->
      <!-- 添加到购物车列 -->
      <el-table-column label="添加到购物车">
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-circle-plus-outline" circle></el-button>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
export default {
  name: "MyCollection",
  data() {
    return {
      tab: [],
      secs: {
        pageNum: 1,
        pageSize: 3,
      },
    };
  },
  methods: {
    fetchData() {
      const data=new FormData();
      data.append("pageNum",this.secs.pageNum)
      data.append("pageSize",this.secs.pageSize)
      this.$http.post('/userInfo/selectCollectRank',data)
      .then(resp => {
        console.log(resp);
        this.tab = resp.data.data; // 确保这个路径匹配
        this.total = resp.data.total; // 假设后端返回了总数
      })
      .catch(err => {
        console.error('获取用户数据失败', err);
      });
    },

  },
  created() {
    this.fetchData();
  }
}
</script>
